package com.zb.admin.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zb.admin.mapper.AdSensitiveMapper;
import com.zb.admin.service.AdSensitiveService;
import com.zb.model.common.PageResult;
import com.zb.model.dto.admin.SensitiveDTO;
import com.zb.model.pojo.admin.AdSensitive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class AdSensitiveServiceImpl implements AdSensitiveService {

    @Autowired
    private AdSensitiveMapper adSensitiveMapper;
    @Override
    public PageResult list(SensitiveDTO dto) {
        Integer page = dto.getPage();
        Integer pageSize = dto.getPageSize();
        PageHelper.startPage(page, pageSize);
        Page<AdSensitive> data = adSensitiveMapper.pageList(dto);
        return PageResult.builder().total(data.getTotal()).rows(data.getResult()).build();
    }

    @Override
    public Integer save(AdSensitive adSensitive) {
        adSensitive.setCreatedTime(new Date());
        return adSensitiveMapper.save(adSensitive);
    }

    @Override
    public Integer update(AdSensitive adSensitive) {
        return adSensitiveMapper.update(adSensitive);
    }

    @Override
    public Integer Del(Integer id) {
        return adSensitiveMapper.del(id);
    }

    @Override
    public AdSensitive getById(Integer id) {
        return adSensitiveMapper.getById(id);
    }
}
